package Acwing.基础算法;

import java.util.Scanner;

/**
 * @Title: dualPoints2
 * @Author 贾金博
 * @Package Acwing.基础算法
 * @Date 2025/4/10 上午10:48
 * @description: 双指针2
 */
public class dualPoints2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n + 10];
        int[] b = new int[n + 10];

        for(int i = 1; i <= n; i ++ ) {
            a[i] = sc.nextInt();
        }

        for(int i = 1; i <= m; i ++ ) {
            b[i] = sc.nextInt();
        }

        // 开始双指针 枚举答案 当然二分也是可以去写的
        for(int i = 1, j = m; i <= n; i ++ ) {
            // 这里保证的是一定是有 解的
            int t = a[i] + b[j];
            while(a[i] + b[j] > x && j > 1) {
                j --;
            }
            if(a[i] + b[j] == x) {
                // 注意下标问题
                System.out.println( (i - 1) + " " + (j - 1) );
                break;
            }

        }

    }
}
